
	<style type="text/css">
		#fm<?=$objectId;?>{
			margin:0;
			padding:10px 30px;
		}
		
	</style>
	<div class="easyui-panel" title="Kriteria Pencarian" style="width:auto;height:150px;padding:10px;"
				data-options="iconCls:'icon-search',collapsible:true,collapsed:true">
		<table border="0" cellpadding="1" cellspacing="1" width="100%">
            <tr>
            <td>
                             
                <table border="0" cellpadding="1" cellspacing="4">				
                <tr>
                    <td><?=form_dropdown('tipe_periode',$tipePeriode,'0','id="tipe_periode'.$objectId.'" ')?></td>
                    <td><input name="periodeawal" style="width:100px" id="periodeawal<?=$objectId;?>" class="easyui-datebox"  data-options="formatter:myDateFormatter,parser:myDateParser"  > s.d. <input name="periodeakhir" style="width:100px" id="periodeakhir<?=$objectId;?>" class="easyui-datebox" data-options="formatter:myDateFormatter,parser:myDateParser"  ></td>
                    <td width="20px">&nbsp;</td>
                    <td>Bidang : &nbsp;</td>
                    <td> <?=$bidanglistFilter?>  </td>
                     <td width="20px">&nbsp;</td>
                    <td>Kategori : &nbsp;</td>
                    <td> <?=$kategorilistFilter?>  </td>
                </tr>
			
					 <tr>
                        <td align="right">No.Urut : &nbsp;</td>
                        <td><input type="text" size="31px" name="txtNomor" style="padding:7px;font-size:14px" id="txtNomor<?=$objectId;?>" class="easyui-validatebox"/></td>
						<td width="20px">&nbsp;</td>
						 <td>Tipe : &nbsp;</td>
                    <td> <select name="tipe" id="tipe<?=$objectId?>" class="easyui-validatebox">
                      <option value="-1" >Semua Tipe</option>
                      <option value="serah" >Serah ke PPK</option>
                      <option value="terima" >Terima dari PPK</option>
                  </select>  </td>
					</tr>	
            
                <tr>
                    <td align="right" colspan="8" valign="top">
                        <a href="#" class="easyui-linkbutton" onclick="clearFilter<?=$objectId;?>();" iconCls="icon-reset">Reset</a>
                        <a href="#" class="easyui-linkbutton" onclick="searchData<?=$objectId;?>();" iconCls="icon-search">Cari</a>
                    </td>
                </tr>
                </table>
              
                </td>
            </tr>
            </table>		
	</div>			
	<div id="tb<?=$objectId;?>" style="height:auto">
            
	  <div style="margin-bottom:5px">
		<? if($this->sys_menu_model->cekAkses('PROSES;',(($tipeapproval=="penguji")?24:23),$this->session->userdata('user_id'),$this->session->userdata('level_id'))){?>
			<a href="#" onclick="newData<?=$objectId;?>('<?=$tipeapproval?>');" class="easyui-linkbutton" iconCls="icon-add" plain="true">Serah/Terima</a>  
		<?}?>
		<? if($this->sys_menu_model->cekAkses('VIEW;',(($tipeapproval=="penguji")?24:23),$this->session->userdata('user_id'),$this->session->userdata('level_id'))){?>
			<a href="#" onclick="editData<?=$objectId;?>(true);" class="easyui-linkbutton" style="display:none" iconCls="icon-view" plain="true">Lihat</a>
		<?}?>
		<? if($this->sys_menu_model->cekAkses('DELETE;',(($tipeapproval=="penguji")?24:23),$this->session->userdata('user_id'),$this->session->userdata('level_id'))){?>
			<a href="#" onclick="deleteData<?=$objectId;?>();" class="easyui-linkbutton" iconCls="icon-remove" plain="true">Hapus</a>
		<?}?>
		<? if($this->sys_menu_model->cekAkses('PRINT;',(($tipeapproval=="penguji")?24:23),$this->session->userdata('user_id'),$this->session->userdata('level_id'))){?>
			<a href="#" onclick="printData<?=$objectId;?>();" class="easyui-linkbutton" iconCls="icon-print" plain="true">Print</a>
		<?}?>
		<? if($this->sys_menu_model->cekAkses('EXCEL;',(($tipeapproval=="penguji")?24:23),$this->session->userdata('user_id'),$this->session->userdata('level_id'))){?>
			<a href="#" onclick="toExcel<?=$objectId;?>();" class="easyui-linkbutton" iconCls="icon-excel" plain="true">Excel</a>
		<?}?>
	  </div>
	</div>
	
	<table id="dg<?=$objectId;?>"  iconCls='icon-save' style="height:auto;width:auto" title="Data Serah/Terima PPK " toolbar="#tb<?=$objectId;?>" 
               fitColumns="true" singleSelect="true" rownumbers="true" pagination="true" noWrap="false" showFooter="true">
	  <thead>
	  <tr>
		<th halign="center" align="left" field="tanggal" sortable="true" width="80">Tanggal</th>
		<th halign="center" align="center" field="nomor" sortable="true" width="100">Nomor</th>
		
		<th halign="center" align="left" field="tipe_text" sortable="true" width="80">Tipe</th>
		
		<th halign="center" align="left" field="penyerah" sortable="true" width="100">Yang Menyerahkan</th>
		<th halign="center" align="left" field="penerima" sortable="true" width="100">Yang Menerima</th>
		<th halign="center" align="left" field="keterangan" sortable="true" width="250">Keterangan</th>
		
		<th halign="center" field="tipe" hidden="true"  width="0">tipe</th>	
		<th halign="center" field="serahterima_id" hidden="true"  width="0">serahterima_id</th>
	  </tr>
         
	  </thead> 
	</table>
	 

	
	<script  type="text/javascript" >
$(function(){
    var url;
    
       
    

    clearFilter<?=$objectId;?> = function (){
        $("#filter_bidang_id<?=$objectId?>").val('-1');
        $("#filter_kategori_id<?=$objectId?>").val('-1');
        $('#periodeawal<?=$objectId;?>').datebox('setValue','<?=date('01-01-Y')?>');
        $('#periodeakhir<?=$objectId;?>').datebox('setValue','<?=date('d-m-Y')?>');
		$("#txtNomor<?=$objectId?>").val('');
		$("#tipe_periode<?=$objectId?>").val('0');
        //$('#dg<?=$objectId;?>').datagrid({url:"<?=base_url()?>transaksi/spb/grid/"+filnip+"/"+filnama+"/"+filalamat});
    }

        //tipe 1=grid, 2=pdf, 3=excel
    getUrl<?=$objectId;?> = function (tipe){
        var filawal =  $('#periodeawal<?=$objectId;?>').datebox('getValue');	
        var filakhir = $("#periodeakhir<?=$objectId;?>").datebox('getValue');	
        var filbidang = $("#filter_bidang_id<?=$objectId;?>").combobox('getValue');
        var filkategori = $("#filter_kategori_id<?=$objectId;?>").val();
        var filnomor = $("#txtNomor<?=$objectId;?>").val();
		var tipeperiode = $("#tipe_periode<?=$objectId?>").val();
		var tipeSerah = $("#tipe<?=$objectId?>").val();
		
         filnomor = ((filnomor=="undefined")||(filnomor=="")||(filnomor==null))?"-1":filnomor;

        filbidang = ((filbidang=="undefined")||(filbidang=="")||(filbidang==null))?"-1":filbidang;
        filkategori = ((filkategori=="undefined")||(filkategori=="")||(filbidang==null))?"-1":filkategori;
        if (tipe==1){
                return "<?=base_url()?>transaksi/serahterima_ppk/grid/"+tipeSerah+"/"+filawal+"/"+filakhir+"/"+filbidang+"/"+filkategori+"/"+filnomor+"/"+tipeperiode;
        }
        else if (tipe==2){
                return "<?=base_url()?>transaksi/serahterima_ppk/pdf/"+tipeSerah+"/"+filawal+"/"+filakhir+"/"+filbidang+"/"+filkategori+"/"+filnomor+"/"+tipeperiode;
        }else if (tipe==3){
                return "<?=base_url()?>transaksi/serahterima_ppk/excel/"+tipeSerah+"/"+filawal+"/"+filakhir+"/"+filbidang+"/"+filkategori+"/"+filnomor+"/"+tipeperiode;
        }

    }

    searchData<?=$objectId;?> = function (){
        //ambil nilai-nilai filter
       

       //ambil nilai-nilai filter
        $('#dg<?=$objectId;?>').datagrid({
            url:getUrl<?=$objectId;?>(1),
            view: detailview,
            detailFormatter:function(index,row){
               return '<div style="padding:2px"><table id="ddv<?=$objectId;?>-' + index + '"></table></div>';
           //  return "tes";
           },
           onExpandRow: function(index,row){
                           //	alert(row.id_pk_e1);

               $('#ddv<?=$objectId;?>-'+index).datagrid({
                   url:'<?=base_url()?>transaksi/serahterima_ppk/griddetail/'+row.tipe+"/"+row.serahterima_id+'/?parentIndex='+index,
                   fitColumns:true,
                   singleSelect:true,
                   rownumbers:true,
                   loadMsg:'',
                   height:'auto',
                   columns:[[
                       {field:'serahterima_id',title:'tanda_id',hidden:true},
                       {field:'spb_id',title:'spb_id',hidden:true},
                       {field:'tanggal',title:'Tanggal',width:80},
                       {field:'nomor',title:'No. Urut',width:200},
                       {field:'jumlah',title:'Jumlah',width:100,align:'right'},
                       {field:'kategori',title:'Kategori',width:100},
                       {field:'untuk',title:'Untuk Pembayaran',width:200}
                       
                   ]],
                   onResize:function(){
                       $('#dg<?=$objectId;?>').datagrid('fixDetailRowHeight',index);
                   },
                  onClickCell:function(rowIndex, field, value){
                        $('#ddv<?=$objectId;?>-'+index).datagrid('selectRow', rowIndex);
                       var row = $('#ddv<?=$objectId;?>-'+index).datagrid('getSelected');
                       idTanda<?=$objectId;?> = row.tanda_id;
                       rowIndexDetail = index;
                                                   //alert(idTanda);
                    },
                   onLoadSuccess:function(){
                       setTimeout(function(){
                           $('#dg<?=$objectId;?>').datagrid('fixDetailRowHeight',index);
                       },0);
                   }
               });
               $('#dg<?=$objectId;?>').datagrid('fixDetailRowHeight',index);


           }
        });
    }
    //end searhData 
	
	newData<?=$objectId;?> = function (){    
        addTab("Tambah Serah/Terima PPK","transaksi/serahterima_ppk/add");
    }
	
   
    
    editData<?=$objectId;?> = function (viewmode){
        var row = $('#dg<?=$objectId;?>').datagrid('getSelected');
        $('#fm<?=$objectId;?>').form('clear');  
        //alert(row.dokter_kode);
        if (row){
                $('#dlg<?=$objectId;?>').dialog('open').dialog('setTitle','Edit SPBY');
                $('#fm<?=$objectId;?>').form('load',row);
                
                if (viewmode){
                    $('#btnApprove<?=$objectId?>').hide();
                    $('#btnTolak<?=$objectId?>').hide();
                }
                else{
                    $('#btnApprove<?=$objectId?>').show();
                    $('#btnTolak<?=$objectId?>').show();
                }    
                    
                url = base_url+'transaksi/spb/save/edit/'+row.spb_id;//+row.id;//'update_user.php?id='+row.id;
        }
    }
        //end editData

    deleteData<?=$objectId;?> = function (){
        var row = $('#dg<?=$objectId;?>').datagrid('getSelected');
        if(row){
            if(confirm("Apakah yakin akan menghapus data '" + row.nomor + "'?")){
                var response = '';
                $.ajax({ type: "GET",
                    url: base_url+'transaksi/spb/delete/' + row.spb_id ,
                    async: false,
                    success : function(response){
                        var response = eval('('+response+')');
                        if (response.success){
                            $.messager.show({
                                title: 'Success',
                                msg: 'Data Berhasil Dihapus'
                            });

                            // reload and close tab
                            $('#dg<?=$objectId;?>').datagrid('reload');
                        } else {
                            $.messager.show({
                                title: 'Error',
                                msg: response.msg
                            });
                        }
                    }
                });
            }
        }
    }
        //end deleteData 

   
    
    printData<?=$objectId;?>=function(){			
        //$.jqURL.loc(getUrl<?=$objectId;?>(2),{w:800,h:600,wintype:"_blank"});
		//alert("underconstruction");return;
        window.open(getUrl<?=$objectId;?>(2));;
    }

    toExcel<?=$objectId;?>=function(){
		//alert("underconstruction");return;
        window.open(getUrl<?=$objectId;?>(3));;
    }
    
   
    
     
   

        setTimeout(function(){
            var wHeight = $(window).height();	
            clearFilter<?=$objectId?>();
            $("#dg<?=$objectId;?>").css('height',wHeight-183);    
            searchData<?=$objectId?>();
        },100);
 });
</script>